<div id="allList" class="adress_li adress_li_active">
    <#if pageBean.content?size gt 0>
        <#list pageBean.content as expressMailOrder>
            <table>
                <tbody>
                <tr>
                    <td class="tableOrder" style="width:200px;text-align: center">
                        <a class="addresColor"
                           href="/home/expressMailOrder/orderDetails?expressMailOrderId=${expressMailOrder.id}">
                            <#if "1" == rsolutionId || "2" == rsolutionId || "3" == rsolutionId || "4" == rsolutionId>
                                <#if expressMailOrder.orderStatus == 0>
                                    <span>已下单</span>
                                <#elseif expressMailOrder.orderStatus == 6>
                                    <span>已完成</span>
                                <#else>
                                    <span>处理中</span>
                                </#if>
                            </#if>
                            <#if "5" == rsolutionId || "6" == rsolutionId || "7" == rsolutionId>
                                <#if expressMailOrder.orderStatus == 6>
                                    <span>已签收</span>
                                <#else>
                                    <span>待签收</span>
                                </#if>
                            </#if>
                            ${expressMailOrder.waybillNumber}
                        </a>
                    </td>
                    <td class="tablePerson" style="width:380px;text-align: center">
                        <span class="addresColor"></span> ${expressMailOrder.senderName}&gt;
                        <span class="addresColor"></span> ${expressMailOrder.recipientsName}
                    </td>
                    <td class="tableTime" style="width:210px;text-align: center">
                        <span></span>
                        <span>${expressMailOrder.createTime}</span>
                    </td>
                    <td class="tablelOperate" style="text-align: center">
                        <#if "1" == rsolutionId || "2" == rsolutionId || "3" == rsolutionId || "4" == rsolutionId>
                            <#if expressMailOrder.orderStatus == 0>
                                <a class="addresColor" data-id="${expressMailOrder.id}"
                                   onclick="delOrderByWaybillNumber(this)" style="text-align: center">取消订单</a>
                            <#elseif expressMailOrder.orderStatus == 6>
                                <a style="cursor: default;color: #ed6c00;" style="text-align: center">已完成</a>
                            <#else>
                                <a style="cursor: default; color: #ed6c00;" style="text-align: center">处理中</a>
                            </#if>
                        </#if>
                        <#if "5" == rsolutionId || "6" == rsolutionId || "7" == rsolutionId>
                            <#if expressMailOrder.orderStatus == 6>
                                <a style="cursor: default;color: #ed6c00;" style="text-align: center">已签收</a>
                            <#else>
                                <a class="addresColor" onclick="setPickUpTime(${expressMailOrder.id})" style="text-align: center;position: relative;right: 17px;" >设置送件上门时间</a>
                                <input type="hidden" data-key="${expressMailOrder.id}" value="${expressMailOrder.pickUpTime!""}">
                            </#if>
                        </#if>

                    </td>
                </tr>
                </tbody>
            </table>
        </#list>
    </#if>

    <input type="hidden" id="totalNum" value="${pageBean.total}">
    <input type="hidden" id="rsolutionIdInput" value="${rsolutionId}">
</div>


<script>
    var curr =
    ${pageBean.currentPage}
    var count = ${pageBean.total}
        $(document).ready(function () {
            layui.use('laypage', function () {
                var laypage = layui.laypage;
                laypage.render({
                    elem: 'page'
                    , theme: '#ee6900'
                    , count: count //数据总数，从服务端得到
                    , limit:${pageBean.pageSize}
                    , curr: curr
                    , jump: function (obj, first) {
                        //首次不执行
                        if (!first) {
                            curr = obj.curr;
                            if (typeof selOrderState === 'function') {
                                selOrderState(curr, ${rsolutionId});
                            } else {
                                IndexByPage(curr)
                            }
                        }
                    }
                });
            });
        });

    function delOrderByWaybillNumber(t) {
        layer.msg('您正在操作删除订单哦!<br>确认后将无法看到该订单的详情消息', {
            time: 3000,
            btn: ['确认', '取消'],
            btn1: function () {
                $.ajax({
                    url: '/home/expressMailOrder/delete',
                    type: 'POST',
                    data: {id: $(t).attr("data-id")},
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg('快递订单删除成功!', function () {

                            })
                            $(t).parents("table").remove();
                        } else {
                            layer.msg(data.msg);
                        }
                    },
                    error: function () {
                        alert('网络错误!');
                    }
                });
            }
        });
    }

    function setPickUpTime(expressMailOrderId){
        let pickUpTime = $("[data-key="+expressMailOrderId+"]").val();
        layer.open({
            title:'设置上门送件时间'
            ,content: '<div style="">上门送件时间:'+pickUpTime+'<input type="text" style="width: 180px" placeholder="请选择上门送件时间"  class="layui-input" id="test1"></div>'
            ,btn: ['确认', '取消']
            ,btnAlign: 'c' //按钮居中
            ,shade: 0 //不显示遮罩
            ,btn1: function () {
                let dateVal = $("#test1").val();
                if (dateVal){
                    $.ajax({
                        url: '/home/expressMailOrder/setPickUpTime',
                        type: 'POST',
                        data: {
                            pickUpTime: dateVal,
                            expressMailOrderId:expressMailOrderId
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data.code == 0) {
                                $("[data-key="+expressMailOrderId+"]").val(dateVal)
                                layer.msg('上门送件时间设置成功!', function () {

                                })
                            } else {
                                layer.msg(data.msg);
                            }
                        },
                        error: function () {
                            alert('网络错误!');
                        }
                    });
                }else {
                    layer.msg("请选择时间!")
                }

            }
        });
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#test1' //指定元素
                ,type: 'datetime'
                ,min: 0
                ,max: 14
            });
        });
    }

</script>